#ifndef ELS_RANOM_H_
#define ELS_RANOM_H_

#include "els.h"
#include "ELS_random_script.h"

#include <stdio.h>

int ELSAPI_random_randseed(els_VmObj *vm);
int ELSAPI_random_random(els_VmObj *vm);
int ELSAPI_random_randint(els_VmObj *vm);
int ELSAPI_random_randfloat(els_VmObj *vm);
int ELSAPI_random_normal(els_VmObj *vm);
int ELSAPI_random_srand(els_VmObj *vm);
int ELSAPI_random_randstr(els_VmObj *vm);
int ELSAPI_random_randbytes(els_VmObj *vm);
int ELSAPI_random_percent(els_VmObj *vm);

void ElsLib_random_libinit(els_VmObj *vm)
{
    LosuObj lib = obj_newunit(vm);

    obj_setunit(vm, lib, obj_newstr(vm, "randseed"), obj_newfunction(vm, ELSAPI_random_randseed));
    obj_setunit(vm, lib, obj_newstr(vm, "random"), obj_newfunction(vm, ELSAPI_random_random));
    obj_setunit(vm, lib, obj_newstr(vm, "randint"), obj_newfunction(vm, ELSAPI_random_randint));
    obj_setunit(vm, lib, obj_newstr(vm, "randfloat"), obj_newfunction(vm, ELSAPI_random_randfloat));
    obj_setunit(vm, lib, obj_newstr(vm, "normal"), obj_newfunction(vm, ELSAPI_random_normal));
    obj_setunit(vm, lib, obj_newstr(vm, "srand"), obj_newfunction(vm, ELSAPI_random_srand));
    obj_setunit(vm, lib, obj_newstr(vm, "randstr"), obj_newfunction(vm, ELSAPI_random_randstr));
    obj_setunit(vm, lib, obj_newstr(vm, "randbytes"), obj_newfunction(vm, ELSAPI_random_randbytes));
    obj_setunit(vm, lib, obj_newstr(vm, "percent"), obj_newfunction(vm, ELSAPI_random_percent));

    vm_setval(vm, "random", &lib);
    vm_dostring(vm, random_script);
}

#endif